package com.wwz.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import java.util.List;

/**
 * <p>Description:查询当前用户的任务列表</p >
 * <p>Copyright: Copyright (c)2021</p >
 * <p>Company: Xueqiu</p >
 * <P>Created Date :2021-04-06</P>
 * <P>@version 1.0</P>
 */
public class ActivitiTaskQuery {
    public static void main(String[] args) {
        //1.得到ProcessEngine
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        //2.得到TaskService对象
        TaskService taskService = processEngine.getTaskService();

        //3.根据流程定义的key，负责人 assignee 来实现当前用户的任务列表查询
        List<Task> taskList = taskService.createTaskQuery()
                .processDefinitionKey("holiday")
                .taskAssignee("wangwu")
                .list();

        //4.任务列表展示
        for (Task task : taskList)  {
            System.out.println("流程实例id"+task.getProcessInstanceId());
            System.out.println("任务Id"+task.getId());
            System.out.println("任务负责人"+task.getAssignee());
            System.out.println("任务名称"+task.getName());
        }

    }
}
